package com.lau.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author Lau
 * @since 2023-11-28
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class SysUser  extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @NotBlank(message = "用户名不能为空")
    private String username;

    private String password;

    private String avatar;

    @NotBlank(message = "邮箱不能为空")
    @Email(message = "邮箱格式不正确")
    private String email;

    private String sex;

    private String phoneNumber;

    private LocalDateTime lastLogin;

    @TableField(exist = false)
    private List<SysRole> sysRoles = new ArrayList<>();

    @TableField(exist = false)
    private String roleName;

    @TableField(exist = false)
    private List<String> roleNameList;


    /** 帐号状态（0正常 1停用 2冻结） */
    @TableField(fill = FieldFill.INSERT)
    private String status;

    /** 删除标志（0代表存在 1代表删除） */
    @TableField(fill = FieldFill.INSERT)
    // 该注解用于逻辑删除
    @TableLogic
    private String delFlag;

}
